package com.sky.utils;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;


public class test {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(new Date());
        System.out.println(format);

//
//        String text ="http://mms0.baidu.com/it/u=143239581,4288659888&fm=253&app=138&f=JPEG?w=500&h=500";//这里设置自定义网站url
//
//        String logoPath ="C:\\Users\\Z\\Desktop\\img\\dog.png";
//
//        String destPath ="C:\\Users\\Z\\Desktop\\img";
//
//        System.out.println(encode(text, logoPath, destPath, true));
    }

    public static String encode(String content, String imgPath,

                                String destPath,boolean needCompress) throws Exception {

        BufferedImage image = QRCodeUtils.createImage(content, imgPath,

                needCompress);


//        mkdirs(destPath);


        String s = UUID.randomUUID().toString();

        String file = s+".jpg";

        ImageIO.write(image, QRCodeUtils.FORMAT_NAME, new File(destPath+"/"+file));

        return file;

    }
}
